import { FC, useState } from "react";
import PreviewToolbar from "./toolbar/PreviewToolbar";
import PreviewProblemTable from "./content/PreviewProblemTable";
import { httpPost } from "@utils/HttpUtil";

const TihaiPreview: FC = () => {

  const prolbemList = httpPost("/problem/getProblemList", {}).data;

  const itemData = prolbemList.map((problem: any) => ({
    href: "https://ant.design",
    title: problem.title,
    avatar: "https://api.dicebear.com/7.x/miniavs/svg?seed=1",
    description: "管理员",
    content: problem,
  }));

  const [data, setData] = useState(itemData);

  const filterData = (data: any) => {
    setData(data);
  };

  return (
    <>
      <PreviewToolbar filterData={filterData} data={data}/>
      <PreviewProblemTable data={data} />
    </>
  );
};

export default TihaiPreview;
